import React, { useEffect, useState } from 'react'
import { Modal } from 'antd'

const Index = ({ show = false, previewTitle, previewImage, onCancel }) => {
  const [currentShow, setCurrentShow] = useState(false)
  const handleCancel = () => {
    setCurrentShow(false)
    onCancel?.()
  }
  useEffect(() => setCurrentShow(show), [show])
  return <Modal className='web-modal' open={currentShow} title={previewTitle} footer={null} onCancel={handleCancel}>
    <img
      alt="pic"
      style={{
        width: '100%',
      }}
      src={previewImage}
    />
</Modal>
}

export default Index
